#include "numberkeyboarddot.h"
#include "ui_numberkeyboarddot.h"

NumberKeyBoardDot::NumberKeyBoardDot(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NumberKeyBoardDot)
{
    ui->setupUi(this);
    m_lNumBtnList.append(ui->Btn_Num0);
    m_lNumBtnList.append(ui->Btn_Num1);
    m_lNumBtnList.append(ui->Btn_Num2);
    m_lNumBtnList.append(ui->Btn_Num3);
    m_lNumBtnList.append(ui->Btn_Num4);
    m_lNumBtnList.append(ui->Btn_Num5);
    m_lNumBtnList.append(ui->Btn_Num6);
    m_lNumBtnList.append(ui->Btn_Num7);
    m_lNumBtnList.append(ui->Btn_Num8);
    m_lNumBtnList.append(ui->Btn_Num9);

    m_pSignalMapper = new QSignalMapper(this);
    for (int i = 0; i < m_lNumBtnList.size(); ++i) {
        connect(m_lNumBtnList[i], SIGNAL(clicked()), m_pSignalMapper, SLOT(map()));
        m_pSignalMapper->setMapping(m_lNumBtnList[i], i);
    }
    connect(m_pSignalMapper, SIGNAL(mapped(int)),this, SIGNAL(setNumber(int)));
}

NumberKeyBoardDot::~NumberKeyBoardDot()
{
    delete ui;
}

void NumberKeyBoardDot::on_Btn_Confirm_clicked()
{
    emit ack();
}

void NumberKeyBoardDot::on_Btn_Cancel_clicked()
{
    emit cancel();
}

void NumberKeyBoardDot::on_Btn_Num_Dot_clicked()
{
    emit dot();
}

void NumberKeyBoardDot::on_Btn_Del_clicked()
{
    emit backspace();
}
